/*
	File: d:/AndyGFX/AGFX_GameStart3D/Projects/AGFX_OO/scripts/box 000.nut
	Author: AndyGFX
*/

/*!
	@short	Box_000
	@author	AndyGFX
*/
class	Box_000 extends TEntity
{
	
	GUI_DIRLIST = 0;
	MENU 		= 0;
	// WINDOW		= 0;
	
	constructor()
	{
		base.constructor()
	}
	
	
	
	/*!
		@short	OnUpdate
		Called during the scene update, each frame.
	*/
	function	OnUpdate(item)
	{
		this.GUI_DIRLIST.Update()
		this.MENU.OnUpdate();
	}

	/*!
		@short	OnSetup
		Called when the item is about to be setup.
	*/
	function	OnSetup(item)
	{
		base.OnSetup(item)
		
		// load used font first
		UILoadFont("fonts/HEMIHEAD.TTF") 
		UILoadFont("fonts/Lifeline.ttf")
		UILoadFont("fonts/casual.ttf")
		
		this.CreateWindow();
		this.CreateDirList();
		this.CreateMenu();
		

	}

	function CreateDirList()
	{
		debug("Create FILE listbox");
		
		this.GUI_DIRLIST = TGUI_Filelistbox();
		this.GUI_DIRLIST.Create("scripts\\lib\\aOO\\","*.nut")	
		this.GUI_DIRLIST.SetPosition(400,300)		
		this.GUI_DIRLIST.OnEnter = this.ExecuteDirList
		this.GUI_DIRLIST.Hide(); 

		
	}
	
	function CreateMenu()
	{
		debug("Create GAME MENU");
		
		this.MENU = TGUI_GameMenu();
		
		this.MENU.AddMenuItem("Load","textures/gui/button_n.png","textures/gui/button_cursor.png",true,"HEMIHEAD",32)
		this.MENU.AddMenuItem("Run","textures/gui/button_n.png","textures/gui/button_cursor.png",false,"HEMIHEAD",32)
		this.MENU.AddMenuItem("Trace","textures/gui/button_n.png","textures/gui/button_cursor.png",false,"HEMIHEAD",32)
		this.MENU.AddMenuItem("Reset","textures/gui/button_n.png","textures/gui/button_cursor.png",false,"HEMIHEAD",32)
		this.MENU.AddMenuItem("Exit","textures/gui/button_n.png","textures/gui/button_cursor.png",false,"HEMIHEAD",32)
		
		
		local size = UIGetInternalResolution(SceneGetUI(g_scene));
		
		this.MENU.SetPosition((size.x/2)-(2.5*128),size.y-128);
		this.MENU.SetKeys(KeyLeftArrow,KeyRightArrow,KeySpace)
		this.MENU.SetItemOffset(128,0)
		this.MENU.SetCaptionOffset(16,64+16);
				
		this.MENU.OnEnter = this.ExecuteMenuButton
		this.MENU.Show();
		
	}	
	
	function CreateSprite()
	{
		debug("Create Sprite");
	}
	
	
	function CreateWindow()
	{
		/*
		debug("Create Window");
		this.WINDOW = TGUI_Window();
		
		this.WINDOW.CreateWindow("Dialog box",512,320,"Lifeline");
		this.WINDOW.SetPosition(0,0) 
		*/

	}
	
	function ExecuteDirList(selected_file_name)
	{

		local self = ItemGetScriptInstance(SceneFindItem(g_scene,"Box_B"))
		self.GUI_DIRLIST.Hide();
		self.MENU.Show();	
		
		
	}
	
	function ExecuteMenuButton(id)
	{
		
		local self = ItemGetScriptInstance(SceneFindItem(g_scene,"Box_B"))
		
		// LOAD
		if (id==0)
		{
			self.GUI_DIRLIST.Show();
			self.MENU.Hide();
			self.enable_script = true
		}
		
		//RUN
		if (id == 1)
		{
			debug("Button #"+id+" pressed");
		}
		
		//TRACE
		if (id == 2)
		{
			debug("Button #"+id+" pressed");
			
		}
		
		// Reset
		if (id == 3)
		{
			
			debug("Button #"+id+" pressed");
		}
		
		// EXIT
		if (id == 4)
		{
			debug("Button #"+id+" pressed");
		}
	}
}
